<?php

class CommodityRequire
{
    /** @var int */
    protected $id = 0;
    /** @var string */
    protected $title = '';
    /** @var string */
    protected $content = '';
    /** @var int */
    protected $min_price = null;
    /** @var int */
    protected $max_price = null;
    /** @var int */
    protected $num = null;
    /** @var string */
    protected $contactType = null;
    /** @var string */
    protected $contactInfo = null;
    /** @var int */
    /** @var int */
    protected $releaseType = null;
    /** @var string */
    protected $releaseTime = '2000-01-01 00:00:00';
    /** @var int */
    protected $userId = 0;
    /** @var int */
    protected $commodityCatId = null;
    /** @var string */
    protected $commodityTagsIdJson = null;
    /** @var int */
    protected $schoolunicode = 0;

    /**
     * @return User
     */
    public function getUser()
    {
        return User_Model::getUserById($this->getUserId());
    }

    public function getUserDisplayName()
    {
        $thatUser = $this->getUser();
        if ($thatUser) {
            return $thatUser->getDisplayName();
        } else {
            return '[用户不存在]';
        }
    }

    public function getCommodityCatName()
    {
        $thatCommodityCategory = CommodityCategory_Model::getCommodityCategoryById($this->getCommodityCatId());
        if ($thatCommodityCategory)
            return $thatCommodityCategory->getName();
        else
            return '[分类不存在]';
    }

    public function getDisplayContactInfo()
    {
        if ($this->getContactInfo()) {
            return $this->getContactInfo();
        }
        return '请留言我';
    }

    /**
     * @return array
     */
    public function getDataArray()
    {
        return array(
            'id'                  => $this->getId(),
            'title'               => $this->getTitle(),
            'content'             => $this->getContent(),
            'minPrice'            => $this->getMinPrice(),
            'maxPrice'            => $this->getMaxPrice(),
            'num'                 => $this->getNum(),
            'contact_type'        => $this->getContactType(),
            'contact_info'        => $this->getContactInfo(),
            'releaseType'         => $this->getReleaseType(),
            'releaseTime'         => $this->getReleaseTime(),
            'userId'              => $this->getUserId(),
            'commodityCatId'      => $this->getCommodityCatId(),
            'commodityTagsIdJson' => $this->getCommodityTagsIdJson()
        );
    }

    /**
     * @return int
     */
    public function getCommodityCatId()
    {
        return $this->commodityCatId;
    }

    /**
     * @param int $commodityCatId
     */
    public function setCommodityCatId($commodityCatId)
    {
        $this->commodityCatId = $commodityCatId;
    }

    /**
     * @return string
     */
    public function getCommodityTagsIdJson()
    {
        return $this->commodityTagsIdJson;
    }

    /**
     * @param string $commodityTagsIdJson
     */
    public function setCommodityTagsIdJson($commodityTagsIdJson)
    {
        $this->commodityTagsIdJson = $commodityTagsIdJson;
    }

    /**
     * @return string
     */
    public function getContent()
    {
        return $this->content;
    }

    /**
     * @param string $content
     */
    public function setContent($content)
    {
        $this->content = $content;
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param int $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     * @return int
     */
    public function getMaxPrice()
    {
        return $this->max_price;
    }

    /**
     * @param int $max_price
     */
    public function setMaxPrice($max_price)
    {
        $this->max_price = $max_price;
    }

    /**
     * @return int
     */
    public function getMinPrice()
    {
        return $this->min_price;
    }

    /**
     * @param int $min_price
     */
    public function setMinPrice($min_price)
    {
        $this->min_price = $min_price;
    }

    /**
     * @return int
     */
    public function getNum()
    {
        return $this->num;
    }

    /**
     * @param int $num
     */
    public function setNum($num)
    {
        $this->num = $num;
    }

    /**
     * @return string
     */
    public function getContactType()
    {
        return $this->contactType;
    }

    /**
     * @param string $contactType
     */
    public function setContactType($contactType)
    {
        $this->contactType = $contactType;
    }

    /**
     * @return string
     */
    public function getContactInfo()
    {
        return $this->contactInfo;
    }

    /**
     * @param string $contactInfo
     */
    public function setContactInfo($contactInfo)
    {
        $this->contactInfo = $contactInfo;
    }

    /**
     * @return string
     */
    public function getReleaseTime()
    {
        return $this->releaseTime;
    }

    /**
     * @param string $releaseTime
     */
    public function setReleaseTime($releaseTime)
    {
        $this->releaseTime = $releaseTime;
    }

    /**
     * @return int
     */
    public function getReleaseType()
    {
        return $this->releaseType;
    }

    /**
     * @param int $releaseType
     */
    public function setReleaseType($releaseType)
    {
        $this->releaseType = $releaseType;
    }

    /**
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * @param string $title
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }

    /**
     * @return int
     */
    public function getUserId()
    {
        return $this->userId;
    }

    /**
     * @param int $userId
     */
    public function setUserId($userId)
    {
        $this->userId = $userId;
    }

    public function getCommodityRequireCommentCount()
    {
        return CommodityRequireComment_Model::countCommodityRequireCommentByCommodityRequireId($this->getId());
    }

    /**
     * @return int
     */
    public function getSchoolunicode()
    {
        return $this->schoolunicode;
    }

    /**
     * @param int $schoolunicode
     */
    public function setSchoolunicode($schoolunicode)
    {
        $this->schoolunicode = $schoolunicode;
    }



}